<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="root">
        <!-- 使用组件 -->
        <School></School>
    </div>

</body>
<script>
    Vue.config.productionTip = false
    const student = Vue.extend({
            name: 'student',
            template: `
        <div>
        <h2>学校名称：{{name}}</h2>
        <h2>学校地址:{{address}}</h2>
        </div>
        `,
            data() {
                return {
                    name: '尚硅谷',
                    address: '北京'
                }
            }
        })
        //定义组件  template中要用div盒子包起来
    const school = Vue.extend({
        name: 'school',
        template: `
        <div>
        <h2>学校名称：{{name}}</h2>
        <h2>学校地址:{{address}}</h2>
        <student></student>//嵌套student组件
        </div>
        `,
        data() {
            return {
                name: '尚硅谷',
                address: '北京'
            }
        }, //定义sutdent的标签
        components: {
            student,
        }
    })

    new Vue({
        el: '#root',
        data: {

        },
        //注册组件
        components: {
            school,

        }
    })
</script>

</html>